package com.example.hu.Appliction;

import android.app.Application;
import android.content.SharedPreferences;
import android.util.DisplayMetrics;

import com.csht.facelib.api.FaceSdk;
import com.csht.facelib.db.DaoManager;
import com.example.hu.Utils.Contants;
import com.example.hu.Utils.SPManager;

import me.jessyan.autosize.AutoSizeConfig;

public class MyApp  extends Application {
    public  static MyApp sApp;

    public static MyApp getApp()
    {
        return sApp;
    }


    public String getToken()
    {
        return SPManager.getInstance().getString(Contants.PREF_KEY_TOKEN, null);
    }
    public String getName()
    {
        return SPManager.getInstance().getString(Contants.NURSE_NAME_TEXT, null);
    }


    public  String    getAlertName(){
        return SPManager.getInstance().getString(Contants.Alert_NAME_TEXT, null);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        sApp = this;
        SPManager.getInstance().init(this);
        FaceSdk.getInstance().init(this);
        DaoManager.getInstance().init(this);

        //初始化相机和布局
        DisplayMetrics dm = getResources().getDisplayMetrics();
        boolean b = dm.widthPixels<dm.heightPixels;
        AutoSizeConfig.getInstance()
                .setDesignWidthInDp(500)
                .setDesignHeightInDp(600)
                .setBaseOnWidth(b);
    }


    public void setToken(String paramString)
    {
        SPManager.getInstance().putString(Contants.PREF_KEY_TOKEN, paramString);
    }

    public void setName(String paramString)
    {
        SPManager.getInstance().putString(Contants.NURSE_NAME_TEXT, paramString);
    }
    public void    setAlertName(String paramString){
        SPManager.getInstance().putString(Contants.Alert_NAME_TEXT, paramString);
    }
}
